package com.hxexp.weixin.test;

import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

import com.hxexp.weixin.common.date.CalendarUtil;
import com.hxexp.weixin.test.runner.JUnit4WithLogClassRunner;

import static org.junit.Assert.assertArrayEquals;

/**
 * 日历工具类测试
 * @author wang.bin
 *
 */
@RunWith(JUnit4WithLogClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CalendarUtilTester {

    @Test
    public void testCase01() {
        int expected = 31;
        int returnValue = CalendarUtil.getDaysOfMonth();
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase02() {
        int expected = 30;
        int returnValue = CalendarUtil.getDaysOfMonth(2016, 4);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase03() {
        int expected = 5;
        int returnValue = CalendarUtil.getWeeksOfMonth(2016, 2);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase04() {
        int expected = 5;
        int returnValue = CalendarUtil.getWeeksOfMonth();
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase05() {
        int expected = 1;
        int returnValue = CalendarUtil.getWeekOfFistDay(2016, 2);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase06() {
        int expected = 2;
        int returnValue = CalendarUtil.getWeekOfFistDay();
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase07() {
        String[][] expect = { { "", "1", "2", "3", "4", "5", "6" }, { "7", "8", "9", "10", "11", "12", "13" },
                { "14", "15", "16", "17", "18", "19", "20" }, { "21", "22", "23", "24", "25", "26", "27" }, { "28", "29", "", "", "", "", "" } };
        String[][] returnValue = CalendarUtil.getCalendarArray(2016, 2);
        assertArrayEquals(expect, returnValue);
    }

    @Test
    public void testCase08() {
        String[][] expect = { { "", "", "1", "2", "3", "4", "5" }, { "6", "7", "8", "9", "10", "11", "12" },
                { "13", "14", "15", "16", "17", "18", "19" }, { "20", "21", "22", "23", "24", "25", "26" }, { "27", "28", "29", "30", "31", "", "" } };
        String[][] returnValue = CalendarUtil.getCalendarArray();
        assertArrayEquals(expect, returnValue);
    }
}
